#include "client1.h"
#include "ui_client1.h"
#include<QTcpSocket>
#include<QHostAddress>
client1::client1(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::client1)
{
    ui->setupUi(this);
    this->setWindowTitle("火车票售票系统客户端");
    this->socket = new QTcpSocket(this);
    socket->connectToHost(QHostAddress::LocalHost,0614);

    connect(this->socket,SIGNAL(connected()),this,SLOT(on_conn));
    connect(this->socket,SIGNAL(readyRead()),this,SLOT(on_readready()));
    connect(socket,&QTcpSocket::readyRead,[=]()

    {
        QString str = socket->readAll();
        ui->textBrowser->setText(str);
    }
    );
}

client1::~client1()
{
    delete ui;
}

void client1::on_conn()
{
    ui->textBrowser->setText("已连接");
}
void client1::on_readready()
{


    ui->textBrowser->setText("");


}

void client1::on_pushButton_2_clicked()
{

}

void client1::on_buy_clicked()
{
    QString str = ui->lineEdit->text();
    socket->write(str.toUtf8().data());
}

void client1::on_information_clicked()
{
}

void client1::on_cancel_clicked()
{

}
